package com.qbw.app.module.common.holder;

import android.content.Context;
import android.view.ViewGroup;

import com.qbw.app.R;
import com.qbw.app.databinding.CommonHolderCountryAreaItemBinding;
import com.qbw.app.model.Country;

/**
 * @author QBW
 * @date 2019/9/16
 */
public class CountryAreaItemHolder extends CommonHolder<Country,
        CommonHolderCountryAreaItemBinding> {

    public CountryAreaItemHolder(Context context, ViewGroup viewParent) {
        super(context, R.layout.common_holder_country_area_item, viewParent);
    }

    @Override
    public void bindData(int position, Country data) {
        super.bindData(position, data);
        mBinding.setCountry(data);
        mBinding.executePendingBindings();
        itemView.setOnClickListener(mClickListenerItem);
    }

    @Override
    protected void onClickItem() {
        super.onClickItem();
        if (mContext instanceof Listener) {
            ((Listener) mContext).onSelectCountryArea(mData);
        }
    }

    public interface Listener {
        void onSelectCountryArea(Country country);
    }
}
